<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
            <el-form-item label="收款账户" prop="receiveAccount">
                <el-select v-model="queryParams.receiveAccount" placeholder="收款账户" clearable style="width: 200px">
                    <el-option v-for="dict in receive_account" :key="dict.value" :label="dict.label" :value="dict.value" />
                </el-select>
            </el-form-item>
            <el-form-item label="传输状态" prop="transferStatus">
                <el-select v-model="queryParams.transferStatus" placeholder="传输状态" clearable style="width: 200px">
                    <el-option v-for="dict in receive_account" :key="dict.value" :label="dict.label" :value="dict.value" />
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
            <right-toolbar v-model:showSearch="showSearch" @queryTable="getLogList"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="logList">
            <el-table-column label="总金额" align="center" prop="amount">
                <template #default="scope">
                    <span>{{ scope.row.amount / 100 || 0 }}</span>
                </template>
            </el-table-column>
            <el-table-column label="手续费" align="center" prop="fees">
                <template #default="scope">
                    <span>{{ scope.row.fees / 100 || 0 }}</span>
                </template>
            </el-table-column>
            <el-table-column label="传输状态" align="center" prop="transferStatus">
                <template #default="scope">
                    <dict-tag :options="transfer_status" :value="scope.row.transferStatus" />
                </template>
            </el-table-column>
            <el-table-column label="收款账户" align="center" prop="receiveAccount">
                <template #default="scope">
                    <dict-tag :options="receive_account" :value="scope.row.receiveAccount" />
                </template>
            </el-table-column>
            <el-table-column label="关闭原因" align="center" prop="errReason" />
            <el-table-column label="创建时间" align="center" prop="createTime">
                <template #default="scope">
                    <span>{{ parseTime(scope.row.createTime) }}</span>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize" @pagination="getLogList" />
        <el-form label-width="100px">
            <div style="text-align: center;margin-left:-120px;margin-top:30px;">
                <el-button @click="close()">返回</el-button>
            </div>
        </el-form>
    </div>
</template>

<script setup name="WalletLog">
import { withdrawalDetailLog } from "@/api/subject/withdrawal";

const route = useRoute();
const router = useRouter();
const { proxy } = getCurrentInstance();

const { receive_account, transfer_status } = proxy.useDict("receive_account", "transfer_status");

const loading = ref(true);
const showSearch = ref(true);
const logList = ref([])
const total = ref(0);

const data = reactive({
    queryParams: {
        pageNum: 1,
        pageSize: 10,
        batchNo: undefined,
        receiveAccount: undefined,
        transferStatus: undefined,
    },
});

const { queryParams } = toRefs(data);
function getLogList() {
    let batchNo = window.localStorage.getItem("batchNo")
    if (batchNo) {
        queryParams.value.batchNo = batchNo
    }
    loading.value = true
    withdrawalDetailLog(queryParams.value).then((response) => {
        loading.value = false
        logList.value = response.rows;
        total.value = response.total;
        window.localStorage.removeItem("batchNo")
    })
}
/** 搜索按钮操作 */
function handleQuery() {
    getLogList();
}
/** 关闭按钮 */
function close() {
    const obj = { path: "/system/withdrawal" };
    proxy.$tab.closeOpenPage(obj);
};
/** 重置按钮操作 */
function resetQuery() {
    proxy.resetForm("queryRef");
    handleQuery();
}

getLogList()
</script>